home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / manchester / 4.1 / findWindow.st < prev    next >
Text File  |  1993-07-24  |  2KB  |  76 lines

  1. "    NAME        findWindow
  2.     AUTHOR        Bernard Horan <bernard@is.morgan.com>
  3.     CONTRIBUTOR    Bernard Horan <bernard@is.morgan.com>
  4.     FUNCTION      produce menu to bring selected window to front
  5.     ST-VERSIONS    4.1
  6.     PREREQUISITES     
  7.     CONFLICTS     
  8.     DISTRIBUTION    world
  9.     VERSION        1.0
  10.     DATE        May 1993
  11.     SUMMARY        Adds an extra item to <window> menu called 'find window'; when selected this produces a list of windows, with a strikeout through those that are collapsed. Selecting a window brings it to the front, or, if it is collapsed, expands it. BH, 7/5/93"
  12.  
  13. 'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 29 September 1992 at 2:06:02 am'!
  14.  
  15.  
  16.  
  17. !StandardSystemController methodsFor: 'menu messages'!
  18.  
  19. findWindow
  20.     "(c) Bernard Horan, 7 May 1993"
  21.     "Produce a menu of window labels in aplha order, with me at the bottom. 
  22.     The user selects a label, and the corresponding window is brought to the 
  23.     front of the window stack. An strikeout indicates that the window is 
  24.     collapsed (and therefore becomes expanded if selected)"
  25.  
  26.     | aController |
  27.     Cursor wait
  28.         showWhile: 
  29.             [| aC labelStream |
  30.             aC := ((ScheduledControllers scheduledControllers select: [:tC | tC ~= self])
  31.                         asSortedCollection: [:x :y | x view label <= y view label]) asOrderedCollection.
  32.             aC add: self.
  33.             labelStream := TextStream on: (String new: aC size * 10).
  34.             aC
  35.                 do: 
  36.                     [:i | 
  37.                     | collapsed |
  38.                     collapsed := i view isCollapsed.
  39.                     collapsed ifTrue: [labelStream emphasis: #strikeout].
  40.                     labelStream nextPutAll: (i view label contractTo: 30).
  41.                     collapsed ifTrue: [labelStream emphasis: #default].
  42.                     labelStream cr].
  43.             labelStream skip: -1.
  44.             labelStream space.
  45.             labelStream nextPutAll: '(me)'.
  46.             aController := (PopUpMenu
  47.                         labels: labelStream contents
  48.                         lines: (Array with: aC size - 1)
  49.                         values: aC)
  50.                         startUpWithHeading: 'Select a Window'].
  51.     aController = 0
  52.         ifFalse: 
  53.             [| window |
  54.             window := aController view.
  55.             window isCollapsed
  56.                 ifTrue: [window expand]
  57.                 ifFalse: [window raise]]! !
  58.  
  59.  
  60. !StandardSystemController class methodsFor: 'class initialization'!
  61.  
  62. initialize
  63.     "Initialize the menu."
  64.  
  65.     "StandardSystemController initialize."
  66.  
  67.     ScheduledBlueButtonMenu := 
  68.         PopUpMenu 
  69.             labels: 'relabel as...\refresh\move\resize\front\back\find window\collapse\close' withCRs 
  70.             lines: #(1 6 7 )
  71.             values: #(#newLabel #display #move #resize #front #back #findWindow #collapse #close ).! !
  72.  
  73. StandardSystemController initialize!
  74.  
  75.  
  76.